import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2024-08-28
 * Time: 16:11
 */
public class Test {


    public static int removeElement(int[] nums, int val) {
        int j = 0;

        for(int i = 0; i < nums.length; i++) {
            if(nums[i] != val) {
                nums[j] = nums[i];
                j++;

            }
        }
        return j;
    }

    public static int removeDuplicates(int[] nums) {
        int j = 1;
        for(int i = 1; i < nums.length; i++) {
            if(nums[i] != nums[i-1]) {
                nums[j] = nums[i];
                j++;
            }
        }
        return j;
    }

    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int end1 = m - 1;
        int end2 = n - 1;
        int end = m + n -1;
        while(end1 >= 0 && end2 >= 0) {
            if(nums1[end1] < nums2[end2]) {
                nums1[end--] = nums2[end2--];
            }else {
                nums1[end--] = nums1[end1--];
            }
        }
        while(end2 >= 0) {
            nums1[end--] = nums2[end2--];
        }
    }

    public static List<List<Integer>> generate(int numRows) {
        List<Integer> list = new ArrayList();
        List<List<Integer>> ret = new ArrayList();
        list.add(1);
        ret.add(list);
        for(int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList();
            curRow.add(1);
            // 添加中间部分
            for(int j = 1; j < i; j++) {
                List<Integer> preRow = ret.get(i-1);
                int val = preRow.get(j) + preRow.get(j-1);
                curRow.add(val);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
    public static void main(String[] args) {

    }
}
